package org.stimuliband.dsp.goertzel;

public class Coefficients {

    final int samplingRate;
    final int probesGroupSize;

    public Coefficients(int samplingRate, int probesGroupSize) {
        this.samplingRate = samplingRate;
        this.probesGroupSize = probesGroupSize;
    }

    double coefficient(int forFrequence) {
        double k = (double) probesGroupSize * (double) forFrequence / (double) samplingRate;
        int roundK = (int) Math.round(k);
        double coeff = 2 * Math.cos(2 * Math.PI * roundK / probesGroupSize);
        return coeff;
    }
}
